package com.hua.yuan.live.view.anchor;

import android.annotation.SuppressLint;
import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.hua.yuan.live.R;
import com.hua.yuan.live.repertory.cloud_data.res.RoomInfoBean;
import com.jet.flowtaglayout.FlowTagLayout;

import java.util.ArrayList;
import java.util.List;

import static android.view.View.GONE;

/**
 * 主播简历的view
 */
public class ResumeView {



    private FlowTagLayout flowTagLayout;

    private TextView tvAutograph;

    private TextView tvHeight;

    private TextView tvWeight;

    private TextView tvJob;

    private TextView tvCity;

    private TextView tvConstellation;

    private List<String> tags=new ArrayList<>();

    private LinearLayout llAnchorRsume;

    private LinearLayout llAnchorTags;

    private TextView tvResumeInfoHidden;


    public  ResumeView(View pView){
        flowTagLayout=pView.findViewById(R.id.flowTagLayout_live_detail);
        tvAutograph=pView.findViewById(R.id.tv_signature_live_detail);
        tvHeight=pView.findViewById(R.id.tv_height_live_detail);
        tvWeight=pView.findViewById(R.id.tv_weight_live_detial);
        tvJob=pView.findViewById(R.id.tv_job_live_detial);
        tvCity=pView.findViewById(R.id.tv_city_live_detial);
        tvConstellation=pView.findViewById(R.id.tv_constellation_live_detial);
        llAnchorRsume=pView.findViewById(R.id.ll_anchor_live_detail);
        llAnchorTags=pView.findViewById(R.id.ll_tags_live_detail);
        tvResumeInfoHidden=pView.findViewById(R.id.tv_personal_live_detail);
    }


    @SuppressLint("StringFormatMatches")
    public void setData(RoomInfoBean pRoomInfoBean, Context pContext){

        if(pRoomInfoBean ==null){
            return;
        }
        //执行赋值的操作

        String autograph=pRoomInfoBean.getAutograph();

        if(TextUtils.isEmpty(autograph)){
            tvAutograph.setVisibility(GONE);
        }else{
            tvAutograph.setText(String.format(pContext.getString(R.string.live_autograph),autograph));
        }

        String constellation=pRoomInfoBean.getConstellation();

        if(TextUtils.isEmpty(constellation)){
            tvConstellation.setVisibility(GONE);
        }else{
            tvConstellation.setText(String.format(pContext.getString(R.string.live_constellation),constellation));
        }
        String city=pRoomInfoBean.getCity();
        if(TextUtils.isEmpty(city)){
            tvCity.setVisibility(GONE);
        }else{
            tvCity.setText(String.format(pContext.getResources().getString(R.string.live_city),city));
        }

        String weight=pRoomInfoBean.getWeight();
        if(TextUtils.isEmpty(weight)){
            tvWeight.setVisibility(View.GONE);
        }else{
            tvWeight.setText(String.format(pContext.getResources().getString(R.string.live_weight),weight));
        }

        String height=pRoomInfoBean.getHeight();
        if(TextUtils.isEmpty(height)){
            tvHeight.setVisibility(GONE);
        }else{
            tvHeight.setText(String.format(pContext.getResources().getString(R.string.live_height),height));
        }
        String profession=pRoomInfoBean.getProfession();
        if(TextUtils.isEmpty(profession)){
            tvJob.setVisibility(GONE);
        }else{
            tvJob.setText(String.format(pContext.getResources().getString(R.string.live_job),profession));
        }

        if(tags.size()>0){
            tags.clear();
        }
        if(pRoomInfoBean.getTags() != null && pRoomInfoBean.getTags().size()>0){
            for(String tag:pRoomInfoBean.getTags()){
                if(!TextUtils.isEmpty(tag)){
                    tags.add(tag);
                }
            }
            flowTagLayout.addTags(tags);
            llAnchorTags.setVisibility(View.VISIBLE);
        }else{
            llAnchorTags.setVisibility(GONE);
        }
    }

    public void setVisible(int  isVisible){

        llAnchorRsume.setVisibility(isVisible);
        tvResumeInfoHidden.setVisibility(isVisible);
    }

}
